package tman.simulator.snapshot;

import common.peer.PeerAddress;
import java.util.ArrayList;


public class PeerInfo {
        private PeerAddress succ;
        private PeerAddress pred;
        private ArrayList<PeerAddress> tmanPartners;
        private ArrayList<PeerAddress> parents;
        private ArrayList<PeerAddress> children;
        private ArrayList<PeerAddress> cyclonPartners;
        private ArrayList<PeerAddress> smallWorldPartners;
        private Integer hopcount;
        private Integer age;
        private Integer secondHopcount;

//-------------------------------------------------------------------
        public PeerInfo(PeerAddress address) {
                this.tmanPartners = new ArrayList<PeerAddress>();
                this.cyclonPartners = new ArrayList<PeerAddress>();
                this.parents = new ArrayList<PeerAddress>();
                this.children = new ArrayList<PeerAddress>();
                age = 0;
        		if(address.isSource() == false)
        		{
        			hopcount = 9999;
        			secondHopcount = 9999;
        		}
        		else
        		{
        			hopcount = 0;
        			secondHopcount = 0;
        		}
        }
        
    	public Integer getHopCount()
    	{
    		return hopcount;
    	}
    	
    	public Integer getSecondHopCount()
    	{
    		return secondHopcount;
    	}
    	
    	public void setSecondHopCount(Integer value)
    	{
    		secondHopcount = value;
    	}
    	
    	public void setHopCount(Integer value)
    	{
    		hopcount = value;
    	}
    	
    	public Integer getAge()
    	{
    		return age;
    	}
    	
    	public void incrementAge()
    	{
    		age++;
    	}

//-------------------------------------------------------------------
        public void updateSuccPred(PeerAddress succ, PeerAddress pred) {
                this.succ = succ;
                this.pred = pred;
        }
        
        public void updateParents(ArrayList<PeerAddress> parents)
        {
        	this.parents = parents;
        }
        
        public void updateChildren(ArrayList<PeerAddress> children)
        {
        	this.children = children;
        }

//-------------------------------------------------------------------
        public void updateTManPartners(ArrayList<PeerAddress> partners) {
                this.tmanPartners = partners;
        }

//-------------------------------------------------------------------
        public void updateCyclonPartners(ArrayList<PeerAddress> partners) {
                this.cyclonPartners = partners;
        }
       
        public void updateSmallWorldPartners(ArrayList<PeerAddress> partners) {
                this.smallWorldPartners = partners;
        }

//-------------------------------------------------------------------
        public PeerAddress getSucc() {
                return this.succ;
        }

//-------------------------------------------------------------------
        public PeerAddress getPred() {
                return this.pred;
        }

//-------------------------------------------------------------------
        public ArrayList<PeerAddress> getTManPartners() {
                return this.tmanPartners;
        }

//-------------------------------------------------------------------
        public ArrayList<PeerAddress> getCyclonPartners() {
                return this.cyclonPartners;
        }
       
        public ArrayList<PeerAddress> getSmallWorldPartners() {
                return this.smallWorldPartners;
        }
        
        public ArrayList<PeerAddress> getParents() {
        	return this.parents;
        }
        
        public ArrayList<PeerAddress> getChildren() {
        	return this.children;
        }
      //-------------------------------------------------------------------
    	public boolean isCyclonPartner(PeerAddress peer) {
    		for (PeerAddress node : this.cyclonPartners) {
    			if (node.equals(peer))
    				return true;
    		}
    		
    		return false;
    	}
}
